{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "kJWWp8FdpqfX"
   },
   "source": [
    "# Youtube Search Analysis Agent\n",
    "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/MervinPraison/PraisonAI/blob/main/cookbooks/notebooks/youtube_search_analysis_agents.ipynb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "JYwxIcTopqfZ"
   },
   "source": [
    "## Dependencies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "id": "zBv5vSdLpqfa"
   },
   "outputs": [],
   "source": [
    "# Install dependencies without output\n",
    "%pip install langchain_community > /dev/null\n",
    "%pip install praisonai[crewai] > /dev/null\n",
    "%pip install duckduckgo_search > /dev/null"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "aSnaCJJFpqfb"
   },
   "source": [
    "## Tools"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "id": "IteZwj6Mpqfc"
   },
   "outputs": [],
   "source": [
    "# ToDo: Youtube Search not shown as action in the output\n",
    "from langchain_community.tools import YouTubeSearchTool"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "vDSw5Pbtpqfc"
   },
   "source": [
    "## YAML Prompt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "XeiazIvkpqfc"
   },
   "outputs": [],
   "source": [
    "agent_yaml = \"\"\"\n",
    "framework: \"crewai\"\n",
    "topic: \"research about the causes of lung disease\"\n",
    "roles:\n",
    "  research_analyst:\n",
    "    role: \"Research Analyst\"\n",
    "    backstory: \"Experienced in analyzing scientific data related to respiratory health.\"\n",
    "    goal: \"Analyze data on lung diseases\"\n",
    "    tasks:\n",
    "      data_analysis:\n",
    "        description: \"Gather and analyze data on the causes and risk factors of lung diseases.\"\n",
    "        expected_output: \"Report detailing key findings on lung disease causes.\"\n",
    "    tools:\n",
    "      - \"YouTubeSearchTool\"\n",
    "  medical_writer:\n",
    "    role: \"Medical Writer\"\n",
    "    backstory: \"Skilled in translating complex medical information into accessible content.\"\n",
    "    goal: \"Compile comprehensive content on lung disease causes\"\n",
    "    tasks:\n",
    "      content_creation:\n",
    "        description: \"Create detailed content summarizing the research findings on lung disease causes.\"\n",
    "        expected_output: \"Document outlining various causes and risk factors of lung diseases.\"\n",
    "    tools: []\n",
    "  editor:\n",
    "    role: \"Editor\"\n",
    "    backstory: \"Proficient in editing medical content for accuracy and clarity.\"\n",
    "    goal: \"Review and refine content on lung disease causes\"\n",
    "    tasks:\n",
    "      content_review:\n",
    "        description: \"Edit and refine the compiled content on lung disease causes for accuracy and coherence.\"\n",
    "        expected_output: \"Finalized document on lung disease causes ready for dissemination.\"\n",
    "    tools: []\n",
    "dependencies: []\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "864-LETxpqfd"
   },
   "source": [
    "## Main"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "8pRgXarApqfe",
    "outputId": "2b0e0b3f-8cee-483b-c16c-b381debb5afd"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[1m\u001b[95m [2024-11-02 12:19:37][DEBUG]: == Working Agent: Research Analyst\u001b[00m\n",
      "\u001b[1m\u001b[95m [2024-11-02 12:19:37][INFO]: == Starting Task: Gather and analyze data on the causes and risk factors of lung diseases.\u001b[00m\n",
      "\n",
      "\n",
      "\u001b[1m> Entering new CrewAgentExecutor chain...\u001b[0m\n",
      "\u001b[32;1m\u001b[1;3mI now can give a great answer. \n",
      "\n",
      "Final Answer: \n",
      "\n",
      "**Report on Causes and Risk Factors of Lung Diseases**\n",
      "\n",
      "**Introduction:**\n",
      "Lung diseases encompass a wide range of conditions affecting the lungs and respiratory system, including chronic obstructive pulmonary disease (COPD), asthma, lung cancer, pneumonia, and interstitial lung disease. Understanding the causes and risk factors associated with these diseases is crucial for prevention and management.\n",
      "\n",
      "**Key Findings:**\n",
      "\n",
      "1. **Environmental Factors:**\n",
      "   - **Air Pollution:** Exposure to particulate matter (PM), nitrogen dioxide (NO2), and sulfur dioxide (SO2) is linked to the development and exacerbation of respiratory diseases. Long-term exposure to poor air quality is associated with increased rates of asthma and COPD.\n",
      "   - **Occupational Hazards:** Certain occupations expose individuals to harmful substances such as asbestos, silica, and coal dust, increasing the risk of lung diseases. Workers in construction, mining, and manufacturing are particularly vulnerable.\n",
      "   - **Secondhand Smoke:** Non-smokers exposed to tobacco smoke are at a heightened risk of developing lung diseases, including lung cancer and COPD.\n",
      "\n",
      "2. **Lifestyle Factors:**\n",
      "   - **Smoking:** The leading cause of lung diseases, smoking is responsible for approximately 85% of lung cancer cases and significantly contributes to the incidence of COPD and chronic bronchitis. The risk is dose-dependent, meaning the more one smokes, the higher the risk.\n",
      "   - **Physical Inactivity:** A sedentary lifestyle can exacerbate respiratory conditions and reduce lung function. Regular physical activity is associated with better respiratory health outcomes.\n",
      "\n",
      "3. **Genetic Predisposition:**\n",
      "   - Genetic factors play a role in the susceptibility to lung diseases. For instance, individuals with a family history of asthma or COPD may be at a higher risk. Genetic mutations, such as those affecting the alpha-1 antitrypsin protein, can lead to conditions like emphysema.\n",
      "\n",
      "4. **Infectious Agents:**\n",
      "   - **Viruses and Bacteria:** Respiratory infections, particularly during childhood, can lead to long-term respiratory issues. Viral infections like respiratory syncytial virus (RSV) and bacterial infections like Streptococcus pneumoniae can contribute to the development of chronic respiratory diseases.\n",
      "   - **Fungal Exposure:** Certain environmental fungi can cause respiratory problems, particularly in immunocompromised individuals. For example, Aspergillus species can lead to allergic bronchopulmonary aspergillosis.\n",
      "\n",
      "5. **Socioeconomic Factors:**\n",
      "   - Individuals from lower socioeconomic backgrounds may have limited access to healthcare, leading to delayed diagnosis and treatment of lung diseases. Factors such as poor housing conditions, lack of education, and limited resources for health promotion further exacerbate vulnerability.\n",
      "\n",
      "6. **Age and Gender:**\n",
      "   - Lung function naturally declines with age, making older adults more susceptible to respiratory diseases. Additionally, men historically have higher rates of smoking-related lung diseases, although the gap has narrowed as smoking rates among women have increased.\n",
      "\n",
      "**Conclusion:**\n",
      "The causes and risk factors of lung diseases are multifaceted and interrelated. Environmental exposures, lifestyle choices, genetic predisposition, infectious agents, socioeconomic status, and demographic factors all contribute to the burden of lung diseases. Addressing these factors through public health initiatives, smoking cessation programs, and improved air quality regulations is crucial for reducing the incidence and impact of lung diseases. Further research is needed to explore the interplay of these factors and develop targeted interventions.\n",
      "\n",
      "**Recommendations:**\n",
      "- Promote public awareness campaigns focused on smoking cessation and the dangers of secondhand smoke.\n",
      "- Implement stricter regulations on air quality and occupational safety standards.\n",
      "- Encourage regular health screenings and access to healthcare services, particularly in at-risk populations.\n",
      "- Invest in research to better understand the genetic and environmental interactions leading to lung diseases.\n",
      "\n",
      "This report provides a comprehensive overview of the causes and risk factors associated with lung diseases, offering insights into potential areas for intervention and further research.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n",
      "\u001b[1m\u001b[92m [2024-11-02 12:19:52][DEBUG]: == [Research Analyst] Task output: **Report on Causes and Risk Factors of Lung Diseases**\n",
      "\n",
      "**Introduction:**\n",
      "Lung diseases encompass a wide range of conditions affecting the lungs and respiratory system, including chronic obstructive pulmonary disease (COPD), asthma, lung cancer, pneumonia, and interstitial lung disease. Understanding the causes and risk factors associated with these diseases is crucial for prevention and management.\n",
      "\n",
      "**Key Findings:**\n",
      "\n",
      "1. **Environmental Factors:**\n",
      "   - **Air Pollution:** Exposure to particulate matter (PM), nitrogen dioxide (NO2), and sulfur dioxide (SO2) is linked to the development and exacerbation of respiratory diseases. Long-term exposure to poor air quality is associated with increased rates of asthma and COPD.\n",
      "   - **Occupational Hazards:** Certain occupations expose individuals to harmful substances such as asbestos, silica, and coal dust, increasing the risk of lung diseases. Workers in construction, mining, and manufacturing are particularly vulnerable.\n",
      "   - **Secondhand Smoke:** Non-smokers exposed to tobacco smoke are at a heightened risk of developing lung diseases, including lung cancer and COPD.\n",
      "\n",
      "2. **Lifestyle Factors:**\n",
      "   - **Smoking:** The leading cause of lung diseases, smoking is responsible for approximately 85% of lung cancer cases and significantly contributes to the incidence of COPD and chronic bronchitis. The risk is dose-dependent, meaning the more one smokes, the higher the risk.\n",
      "   - **Physical Inactivity:** A sedentary lifestyle can exacerbate respiratory conditions and reduce lung function. Regular physical activity is associated with better respiratory health outcomes.\n",
      "\n",
      "3. **Genetic Predisposition:**\n",
      "   - Genetic factors play a role in the susceptibility to lung diseases. For instance, individuals with a family history of asthma or COPD may be at a higher risk. Genetic mutations, such as those affecting the alpha-1 antitrypsin protein, can lead to conditions like emphysema.\n",
      "\n",
      "4. **Infectious Agents:**\n",
      "   - **Viruses and Bacteria:** Respiratory infections, particularly during childhood, can lead to long-term respiratory issues. Viral infections like respiratory syncytial virus (RSV) and bacterial infections like Streptococcus pneumoniae can contribute to the development of chronic respiratory diseases.\n",
      "   - **Fungal Exposure:** Certain environmental fungi can cause respiratory problems, particularly in immunocompromised individuals. For example, Aspergillus species can lead to allergic bronchopulmonary aspergillosis.\n",
      "\n",
      "5. **Socioeconomic Factors:**\n",
      "   - Individuals from lower socioeconomic backgrounds may have limited access to healthcare, leading to delayed diagnosis and treatment of lung diseases. Factors such as poor housing conditions, lack of education, and limited resources for health promotion further exacerbate vulnerability.\n",
      "\n",
      "6. **Age and Gender:**\n",
      "   - Lung function naturally declines with age, making older adults more susceptible to respiratory diseases. Additionally, men historically have higher rates of smoking-related lung diseases, although the gap has narrowed as smoking rates among women have increased.\n",
      "\n",
      "**Conclusion:**\n",
      "The causes and risk factors of lung diseases are multifaceted and interrelated. Environmental exposures, lifestyle choices, genetic predisposition, infectious agents, socioeconomic status, and demographic factors all contribute to the burden of lung diseases. Addressing these factors through public health initiatives, smoking cessation programs, and improved air quality regulations is crucial for reducing the incidence and impact of lung diseases. Further research is needed to explore the interplay of these factors and develop targeted interventions.\n",
      "\n",
      "**Recommendations:**\n",
      "- Promote public awareness campaigns focused on smoking cessation and the dangers of secondhand smoke.\n",
      "- Implement stricter regulations on air quality and occupational safety standards.\n",
      "- Encourage regular health screenings and access to healthcare services, particularly in at-risk populations.\n",
      "- Invest in research to better understand the genetic and environmental interactions leading to lung diseases.\n",
      "\n",
      "This report provides a comprehensive overview of the causes and risk factors associated with lung diseases, offering insights into potential areas for intervention and further research.\n",
      "\n",
      "\u001b[00m\n",
      "\u001b[1m\u001b[95m [2024-11-02 12:19:52][DEBUG]: == Working Agent: Medical Writer\u001b[00m\n",
      "\u001b[1m\u001b[95m [2024-11-02 12:19:52][INFO]: == Starting Task: Create detailed content summarizing the research findings on lung disease causes.\u001b[00m\n",
      "\n",
      "\n",
      "\u001b[1m> Entering new CrewAgentExecutor chain...\u001b[0m\n",
      "\u001b[32;1m\u001b[1;3mI now can give a great answer  \n",
      "Final Answer:  \n",
      "\n",
      "**Report on Causes and Risk Factors of Lung Diseases**\n",
      "\n",
      "**Introduction:**  \n",
      "Lung diseases encompass a wide range of conditions affecting the lungs and respiratory system, including chronic obstructive pulmonary disease (COPD), asthma, lung cancer, pneumonia, and interstitial lung disease. Understanding the causes and risk factors associated with these diseases is crucial for prevention and management.\n",
      "\n",
      "**Key Findings:**\n",
      "\n",
      "1. **Environmental Factors:**\n",
      "   - **Air Pollution:** Exposure to particulate matter (PM), nitrogen dioxide (NO2), and sulfur dioxide (SO2) is linked to the development and exacerbation of respiratory diseases. Long-term exposure to poor air quality is associated with increased rates of asthma and COPD. Studies have shown that urban areas with high traffic emissions often correlate with higher incidences of respiratory illnesses among residents.\n",
      "   - **Occupational Hazards:** Certain occupations expose individuals to harmful substances such as asbestos, silica, and coal dust, increasing the risk of lung diseases. Workers in construction, mining, and manufacturing are particularly vulnerable. For instance, miners are at risk of pneumoconiosis, a lung disease caused by inhaling coal dust.\n",
      "   - **Secondhand Smoke:** Non-smokers exposed to tobacco smoke are at a heightened risk of developing lung diseases, including lung cancer and COPD. The World Health Organization reports that secondhand smoke exposure contributes to approximately 1.2 million premature deaths annually.\n",
      "\n",
      "2. **Lifestyle Factors:**\n",
      "   - **Smoking:** The leading cause of lung diseases, smoking is responsible for approximately 85% of lung cancer cases and significantly contributes to the incidence of COPD and chronic bronchitis. The risk is dose-dependent, meaning the more one smokes, the higher the risk. Quitting smoking can lead to substantial reductions in risk over time.\n",
      "   - **Physical Inactivity:** A sedentary lifestyle can exacerbate respiratory conditions and reduce lung function. Regular physical activity is associated with better respiratory health outcomes, helping to maintain optimal lung function and improve overall well-being.\n",
      "\n",
      "3. **Genetic Predisposition:**\n",
      "   - Genetic factors play a role in the susceptibility to lung diseases. For instance, individuals with a family history of asthma or COPD may be at a higher risk. Genetic mutations, such as those affecting the alpha-1 antitrypsin protein, can lead to conditions like emphysema. Advances in genetic research are paving the way for personalized medicine and targeted therapies based on individual genetic profiles.\n",
      "\n",
      "4. **Infectious Agents:**\n",
      "   - **Viruses and Bacteria:** Respiratory infections, particularly during childhood, can lead to long-term respiratory issues. Viral infections like respiratory syncytial virus (RSV) and bacterial infections like Streptococcus pneumoniae can contribute to the development of chronic respiratory diseases. For example, children with severe RSV infections may be at an increased risk for developing asthma later in life.\n",
      "   - **Fungal Exposure:** Certain environmental fungi can cause respiratory problems, particularly in immunocompromised individuals. For example, Aspergillus species can lead to allergic bronchopulmonary aspergillosis, a condition characterized by wheezing and coughing.\n",
      "\n",
      "5. **Socioeconomic Factors:**\n",
      "   - Individuals from lower socioeconomic backgrounds may have limited access to healthcare, leading to delayed diagnosis and treatment of lung diseases. Factors such as poor housing conditions, lack of education, and limited resources for health promotion further exacerbate vulnerability. Inadequate access to preventive services and early interventions can lead to worse health outcomes and higher healthcare costs for these populations.\n",
      "\n",
      "6. **Age and Gender:**\n",
      "   - Lung function naturally declines with age, making older adults more susceptible to respiratory diseases. Additionally, men historically have higher rates of smoking-related lung diseases, although the gap has narrowed as smoking rates among women have increased. Age-related changes in lung structure and function necessitate tailored interventions for older adults at risk of respiratory diseases.\n",
      "\n",
      "**Conclusion:**  \n",
      "The causes and risk factors of lung diseases are multifaceted and interrelated. Environmental exposures, lifestyle choices, genetic predisposition, infectious agents, socioeconomic status, and demographic factors all contribute to the burden of lung diseases. Addressing these factors through public health initiatives, smoking cessation programs, and improved air quality regulations is crucial for reducing the incidence and impact of lung diseases. Further research is needed to explore the interplay of these factors and develop targeted interventions.\n",
      "\n",
      "**Recommendations:**\n",
      "- Promote public awareness campaigns focused on smoking cessation and the dangers of secondhand smoke.\n",
      "- Implement stricter regulations on air quality and occupational safety standards.\n",
      "- Encourage regular health screenings and access to healthcare services, particularly in at-risk populations.\n",
      "- Invest in research to better understand the genetic and environmental interactions leading to lung diseases.\n",
      "\n",
      "This report provides a comprehensive overview of the causes and risk factors associated with lung diseases, offering insights into potential areas for intervention and further research.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n",
      "\u001b[1m\u001b[92m [2024-11-02 12:20:08][DEBUG]: == [Medical Writer] Task output: **Report on Causes and Risk Factors of Lung Diseases**\n",
      "\n",
      "**Introduction:**  \n",
      "Lung diseases encompass a wide range of conditions affecting the lungs and respiratory system, including chronic obstructive pulmonary disease (COPD), asthma, lung cancer, pneumonia, and interstitial lung disease. Understanding the causes and risk factors associated with these diseases is crucial for prevention and management.\n",
      "\n",
      "**Key Findings:**\n",
      "\n",
      "1. **Environmental Factors:**\n",
      "   - **Air Pollution:** Exposure to particulate matter (PM), nitrogen dioxide (NO2), and sulfur dioxide (SO2) is linked to the development and exacerbation of respiratory diseases. Long-term exposure to poor air quality is associated with increased rates of asthma and COPD. Studies have shown that urban areas with high traffic emissions often correlate with higher incidences of respiratory illnesses among residents.\n",
      "   - **Occupational Hazards:** Certain occupations expose individuals to harmful substances such as asbestos, silica, and coal dust, increasing the risk of lung diseases. Workers in construction, mining, and manufacturing are particularly vulnerable. For instance, miners are at risk of pneumoconiosis, a lung disease caused by inhaling coal dust.\n",
      "   - **Secondhand Smoke:** Non-smokers exposed to tobacco smoke are at a heightened risk of developing lung diseases, including lung cancer and COPD. The World Health Organization reports that secondhand smoke exposure contributes to approximately 1.2 million premature deaths annually.\n",
      "\n",
      "2. **Lifestyle Factors:**\n",
      "   - **Smoking:** The leading cause of lung diseases, smoking is responsible for approximately 85% of lung cancer cases and significantly contributes to the incidence of COPD and chronic bronchitis. The risk is dose-dependent, meaning the more one smokes, the higher the risk. Quitting smoking can lead to substantial reductions in risk over time.\n",
      "   - **Physical Inactivity:** A sedentary lifestyle can exacerbate respiratory conditions and reduce lung function. Regular physical activity is associated with better respiratory health outcomes, helping to maintain optimal lung function and improve overall well-being.\n",
      "\n",
      "3. **Genetic Predisposition:**\n",
      "   - Genetic factors play a role in the susceptibility to lung diseases. For instance, individuals with a family history of asthma or COPD may be at a higher risk. Genetic mutations, such as those affecting the alpha-1 antitrypsin protein, can lead to conditions like emphysema. Advances in genetic research are paving the way for personalized medicine and targeted therapies based on individual genetic profiles.\n",
      "\n",
      "4. **Infectious Agents:**\n",
      "   - **Viruses and Bacteria:** Respiratory infections, particularly during childhood, can lead to long-term respiratory issues. Viral infections like respiratory syncytial virus (RSV) and bacterial infections like Streptococcus pneumoniae can contribute to the development of chronic respiratory diseases. For example, children with severe RSV infections may be at an increased risk for developing asthma later in life.\n",
      "   - **Fungal Exposure:** Certain environmental fungi can cause respiratory problems, particularly in immunocompromised individuals. For example, Aspergillus species can lead to allergic bronchopulmonary aspergillosis, a condition characterized by wheezing and coughing.\n",
      "\n",
      "5. **Socioeconomic Factors:**\n",
      "   - Individuals from lower socioeconomic backgrounds may have limited access to healthcare, leading to delayed diagnosis and treatment of lung diseases. Factors such as poor housing conditions, lack of education, and limited resources for health promotion further exacerbate vulnerability. Inadequate access to preventive services and early interventions can lead to worse health outcomes and higher healthcare costs for these populations.\n",
      "\n",
      "6. **Age and Gender:**\n",
      "   - Lung function naturally declines with age, making older adults more susceptible to respiratory diseases. Additionally, men historically have higher rates of smoking-related lung diseases, although the gap has narrowed as smoking rates among women have increased. Age-related changes in lung structure and function necessitate tailored interventions for older adults at risk of respiratory diseases.\n",
      "\n",
      "**Conclusion:**  \n",
      "The causes and risk factors of lung diseases are multifaceted and interrelated. Environmental exposures, lifestyle choices, genetic predisposition, infectious agents, socioeconomic status, and demographic factors all contribute to the burden of lung diseases. Addressing these factors through public health initiatives, smoking cessation programs, and improved air quality regulations is crucial for reducing the incidence and impact of lung diseases. Further research is needed to explore the interplay of these factors and develop targeted interventions.\n",
      "\n",
      "**Recommendations:**\n",
      "- Promote public awareness campaigns focused on smoking cessation and the dangers of secondhand smoke.\n",
      "- Implement stricter regulations on air quality and occupational safety standards.\n",
      "- Encourage regular health screenings and access to healthcare services, particularly in at-risk populations.\n",
      "- Invest in research to better understand the genetic and environmental interactions leading to lung diseases.\n",
      "\n",
      "This report provides a comprehensive overview of the causes and risk factors associated with lung diseases, offering insights into potential areas for intervention and further research.\n",
      "\n",
      "\u001b[00m\n",
      "\u001b[1m\u001b[95m [2024-11-02 12:20:08][DEBUG]: == Working Agent: Editor\u001b[00m\n",
      "\u001b[1m\u001b[95m [2024-11-02 12:20:08][INFO]: == Starting Task: Edit and refine the compiled content on lung disease causes for accuracy and coherence.\u001b[00m\n",
      "\n",
      "\n",
      "\u001b[1m> Entering new CrewAgentExecutor chain...\u001b[0m\n",
      "\u001b[32;1m\u001b[1;3mI now can give a great answer  \n",
      "Final Answer: \n",
      "\n",
      "**Report on Causes and Risk Factors of Lung Diseases**\n",
      "\n",
      "**Introduction:**  \n",
      "Lung diseases encompass a wide range of conditions affecting the lungs and respiratory system, including chronic obstructive pulmonary disease (COPD), asthma, lung cancer, pneumonia, and interstitial lung disease. Understanding the causes and risk factors associated with these diseases is crucial for prevention and management.\n",
      "\n",
      "**Key Findings:**\n",
      "\n",
      "1. **Environmental Factors:**\n",
      "   - **Air Pollution:** Exposure to particulate matter (PM), nitrogen dioxide (NO2), and sulfur dioxide (SO2) is linked to the development and exacerbation of respiratory diseases. Long-term exposure to poor air quality is associated with increased rates of asthma and COPD. Studies have shown that urban areas with high traffic emissions often correlate with higher incidences of respiratory illnesses among residents.\n",
      "   - **Occupational Hazards:** Certain occupations expose individuals to harmful substances such as asbestos, silica, and coal dust, increasing the risk of lung diseases. Workers in construction, mining, and manufacturing are particularly vulnerable. For instance, miners are at risk of pneumoconiosis, a lung disease caused by inhaling coal dust.\n",
      "   - **Secondhand Smoke:** Non-smokers exposed to tobacco smoke are at a heightened risk of developing lung diseases, including lung cancer and COPD. The World Health Organization reports that secondhand smoke exposure contributes to approximately 1.2 million premature deaths annually.\n",
      "\n",
      "2. **Lifestyle Factors:**\n",
      "   - **Smoking:** The leading cause of lung diseases, smoking is responsible for approximately 85% of lung cancer cases and significantly contributes to the incidence of COPD and chronic bronchitis. The risk is dose-dependent, meaning the more one smokes, the higher the risk. Quitting smoking can lead to substantial reductions in risk over time, improving lung health and overall quality of life.\n",
      "   - **Physical Inactivity:** A sedentary lifestyle can exacerbate respiratory conditions and reduce lung function. Regular physical activity is associated with better respiratory health outcomes, helping to maintain optimal lung function and improve overall well-being.\n",
      "\n",
      "3. **Genetic Predisposition:**\n",
      "   - Genetic factors play a role in the susceptibility to lung diseases. For instance, individuals with a family history of asthma or COPD may be at a higher risk. Genetic mutations, such as those affecting the alpha-1 antitrypsin protein, can lead to conditions like emphysema. Advances in genetic research are paving the way for personalized medicine and targeted therapies based on individual genetic profiles.\n",
      "\n",
      "4. **Infectious Agents:**\n",
      "   - **Viruses and Bacteria:** Respiratory infections, particularly during childhood, can lead to long-term respiratory issues. Viral infections like respiratory syncytial virus (RSV) and bacterial infections like Streptococcus pneumoniae can contribute to the development of chronic respiratory diseases. For example, children with severe RSV infections may be at an increased risk for developing asthma later in life.\n",
      "   - **Fungal Exposure:** Certain environmental fungi can cause respiratory problems, particularly in immunocompromised individuals. For example, Aspergillus species can lead to allergic bronchopulmonary aspergillosis, a condition characterized by wheezing and coughing.\n",
      "\n",
      "5. **Socioeconomic Factors:**\n",
      "   - Individuals from lower socioeconomic backgrounds may have limited access to healthcare, leading to delayed diagnosis and treatment of lung diseases. Factors such as poor housing conditions, lack of education, and limited resources for health promotion further exacerbate vulnerability. Inadequate access to preventive services and early interventions can lead to worse health outcomes and higher healthcare costs for these populations.\n",
      "\n",
      "6. **Age and Gender:**\n",
      "   - Lung function naturally declines with age, making older adults more susceptible to respiratory diseases. Additionally, men historically have higher rates of smoking-related lung diseases, although the gap has narrowed as smoking rates among women have increased. Age-related changes in lung structure and function necessitate tailored interventions for older adults at risk of respiratory diseases.\n",
      "\n",
      "**Conclusion:**  \n",
      "The causes and risk factors of lung diseases are multifaceted and interrelated. Environmental exposures, lifestyle choices, genetic predisposition, infectious agents, socioeconomic status, and demographic factors all contribute to the burden of lung diseases. Addressing these factors through public health initiatives, smoking cessation programs, and improved air quality regulations is crucial for reducing the incidence and impact of lung diseases. Further research is needed to explore the interplay of these factors and develop targeted interventions.\n",
      "\n",
      "**Recommendations:**\n",
      "- Promote public awareness campaigns focused on smoking cessation and the dangers of secondhand smoke.\n",
      "- Implement stricter regulations on air quality and occupational safety standards.\n",
      "- Encourage regular health screenings and access to healthcare services, particularly in at-risk populations.\n",
      "- Invest in research to better understand the genetic and environmental interactions leading to lung diseases.\n",
      "\n",
      "This report provides a comprehensive overview of the causes and risk factors associated with lung diseases, offering insights into potential areas for intervention and further research.\u001b[0m\n",
      "\n",
      "\u001b[1m> Finished chain.\u001b[0m\n",
      "\u001b[1m\u001b[92m [2024-11-02 12:20:21][DEBUG]: == [Editor] Task output: **Report on Causes and Risk Factors of Lung Diseases**\n",
      "\n",
      "**Introduction:**  \n",
      "Lung diseases encompass a wide range of conditions affecting the lungs and respiratory system, including chronic obstructive pulmonary disease (COPD), asthma, lung cancer, pneumonia, and interstitial lung disease. Understanding the causes and risk factors associated with these diseases is crucial for prevention and management.\n",
      "\n",
      "**Key Findings:**\n",
      "\n",
      "1. **Environmental Factors:**\n",
      "   - **Air Pollution:** Exposure to particulate matter (PM), nitrogen dioxide (NO2), and sulfur dioxide (SO2) is linked to the development and exacerbation of respiratory diseases. Long-term exposure to poor air quality is associated with increased rates of asthma and COPD. Studies have shown that urban areas with high traffic emissions often correlate with higher incidences of respiratory illnesses among residents.\n",
      "   - **Occupational Hazards:** Certain occupations expose individuals to harmful substances such as asbestos, silica, and coal dust, increasing the risk of lung diseases. Workers in construction, mining, and manufacturing are particularly vulnerable. For instance, miners are at risk of pneumoconiosis, a lung disease caused by inhaling coal dust.\n",
      "   - **Secondhand Smoke:** Non-smokers exposed to tobacco smoke are at a heightened risk of developing lung diseases, including lung cancer and COPD. The World Health Organization reports that secondhand smoke exposure contributes to approximately 1.2 million premature deaths annually.\n",
      "\n",
      "2. **Lifestyle Factors:**\n",
      "   - **Smoking:** The leading cause of lung diseases, smoking is responsible for approximately 85% of lung cancer cases and significantly contributes to the incidence of COPD and chronic bronchitis. The risk is dose-dependent, meaning the more one smokes, the higher the risk. Quitting smoking can lead to substantial reductions in risk over time, improving lung health and overall quality of life.\n",
      "   - **Physical Inactivity:** A sedentary lifestyle can exacerbate respiratory conditions and reduce lung function. Regular physical activity is associated with better respiratory health outcomes, helping to maintain optimal lung function and improve overall well-being.\n",
      "\n",
      "3. **Genetic Predisposition:**\n",
      "   - Genetic factors play a role in the susceptibility to lung diseases. For instance, individuals with a family history of asthma or COPD may be at a higher risk. Genetic mutations, such as those affecting the alpha-1 antitrypsin protein, can lead to conditions like emphysema. Advances in genetic research are paving the way for personalized medicine and targeted therapies based on individual genetic profiles.\n",
      "\n",
      "4. **Infectious Agents:**\n",
      "   - **Viruses and Bacteria:** Respiratory infections, particularly during childhood, can lead to long-term respiratory issues. Viral infections like respiratory syncytial virus (RSV) and bacterial infections like Streptococcus pneumoniae can contribute to the development of chronic respiratory diseases. For example, children with severe RSV infections may be at an increased risk for developing asthma later in life.\n",
      "   - **Fungal Exposure:** Certain environmental fungi can cause respiratory problems, particularly in immunocompromised individuals. For example, Aspergillus species can lead to allergic bronchopulmonary aspergillosis, a condition characterized by wheezing and coughing.\n",
      "\n",
      "5. **Socioeconomic Factors:**\n",
      "   - Individuals from lower socioeconomic backgrounds may have limited access to healthcare, leading to delayed diagnosis and treatment of lung diseases. Factors such as poor housing conditions, lack of education, and limited resources for health promotion further exacerbate vulnerability. Inadequate access to preventive services and early interventions can lead to worse health outcomes and higher healthcare costs for these populations.\n",
      "\n",
      "6. **Age and Gender:**\n",
      "   - Lung function naturally declines with age, making older adults more susceptible to respiratory diseases. Additionally, men historically have higher rates of smoking-related lung diseases, although the gap has narrowed as smoking rates among women have increased. Age-related changes in lung structure and function necessitate tailored interventions for older adults at risk of respiratory diseases.\n",
      "\n",
      "**Conclusion:**  \n",
      "The causes and risk factors of lung diseases are multifaceted and interrelated. Environmental exposures, lifestyle choices, genetic predisposition, infectious agents, socioeconomic status, and demographic factors all contribute to the burden of lung diseases. Addressing these factors through public health initiatives, smoking cessation programs, and improved air quality regulations is crucial for reducing the incidence and impact of lung diseases. Further research is needed to explore the interplay of these factors and develop targeted interventions.\n",
      "\n",
      "**Recommendations:**\n",
      "- Promote public awareness campaigns focused on smoking cessation and the dangers of secondhand smoke.\n",
      "- Implement stricter regulations on air quality and occupational safety standards.\n",
      "- Encourage regular health screenings and access to healthcare services, particularly in at-risk populations.\n",
      "- Invest in research to better understand the genetic and environmental interactions leading to lung diseases.\n",
      "\n",
      "This report provides a comprehensive overview of the causes and risk factors associated with lung diseases, offering insights into potential areas for intervention and further research.\n",
      "\n",
      "\u001b[00m\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">### Task Output ###\n",
       "**Report on Causes and Risk Factors of Lung Diseases**\n",
       "\n",
       "**Introduction:**  \n",
       "Lung diseases encompass a wide range of conditions affecting the lungs and respiratory system, including chronic \n",
       "obstructive pulmonary disease <span style=\"font-weight: bold\">(</span>COPD<span style=\"font-weight: bold\">)</span>, asthma, lung cancer, pneumonia, and interstitial lung disease. Understanding \n",
       "the causes and risk factors associated with these diseases is crucial for prevention and management.\n",
       "\n",
       "**Key Findings:**\n",
       "\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span>. **Environmental Factors:**\n",
       "   - **Air Pollution:** Exposure to particulate matter <span style=\"font-weight: bold\">(</span>PM<span style=\"font-weight: bold\">)</span>, nitrogen dioxide <span style=\"font-weight: bold\">(</span>NO2<span style=\"font-weight: bold\">)</span>, and sulfur dioxide <span style=\"font-weight: bold\">(</span>SO2<span style=\"font-weight: bold\">)</span> is \n",
       "linked to the development and exacerbation of respiratory diseases. Long-term exposure to poor air quality is \n",
       "associated with increased rates of asthma and COPD. Studies have shown that urban areas with high traffic emissions\n",
       "often correlate with higher incidences of respiratory illnesses among residents.\n",
       "   - **Occupational Hazards:** Certain occupations expose individuals to harmful substances such as asbestos, \n",
       "silica, and coal dust, increasing the risk of lung diseases. Workers in construction, mining, and manufacturing are\n",
       "particularly vulnerable. For instance, miners are at risk of pneumoconiosis, a lung disease caused by inhaling coal\n",
       "dust.\n",
       "   - **Secondhand Smoke:** Non-smokers exposed to tobacco smoke are at a heightened risk of developing lung \n",
       "diseases, including lung cancer and COPD. The World Health Organization reports that secondhand smoke exposure \n",
       "contributes to approximately <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1.2</span> million premature deaths annually.\n",
       "\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2</span>. **Lifestyle Factors:**\n",
       "   - **Smoking:** The leading cause of lung diseases, smoking is responsible for approximately <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">85</span>% of lung cancer \n",
       "cases and significantly contributes to the incidence of COPD and chronic bronchitis. The risk is dose-dependent, \n",
       "meaning the more one smokes, the higher the risk. Quitting smoking can lead to substantial reductions in risk over \n",
       "time, improving lung health and overall quality of life.\n",
       "   - **Physical Inactivity:** A sedentary lifestyle can exacerbate respiratory conditions and reduce lung function.\n",
       "Regular physical activity is associated with better respiratory health outcomes, helping to maintain optimal lung \n",
       "function and improve overall well-being.\n",
       "\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3</span>. **Genetic Predisposition:**\n",
       "   - Genetic factors play a role in the susceptibility to lung diseases. For instance, individuals with a family \n",
       "history of asthma or COPD may be at a higher risk. Genetic mutations, such as those affecting the alpha-<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span> \n",
       "antitrypsin protein, can lead to conditions like emphysema. Advances in genetic research are paving the way for \n",
       "personalized medicine and targeted therapies based on individual genetic profiles.\n",
       "\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">4</span>. **Infectious Agents:**\n",
       "   - **Viruses and Bacteria:** Respiratory infections, particularly during childhood, can lead to long-term \n",
       "respiratory issues. Viral infections like respiratory syncytial virus <span style=\"font-weight: bold\">(</span>RSV<span style=\"font-weight: bold\">)</span> and bacterial infections like \n",
       "Streptococcus pneumoniae can contribute to the development of chronic respiratory diseases. For example, children \n",
       "with severe RSV infections may be at an increased risk for developing asthma later in life.\n",
       "   - **Fungal Exposure:** Certain environmental fungi can cause respiratory problems, particularly in \n",
       "immunocompromised individuals. For example, Aspergillus species can lead to allergic bronchopulmonary \n",
       "aspergillosis, a condition characterized by wheezing and coughing.\n",
       "\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5</span>. **Socioeconomic Factors:**\n",
       "   - Individuals from lower socioeconomic backgrounds may have limited access to healthcare, leading to delayed \n",
       "diagnosis and treatment of lung diseases. Factors such as poor housing conditions, lack of education, and limited \n",
       "resources for health promotion further exacerbate vulnerability. Inadequate access to preventive services and early\n",
       "interventions can lead to worse health outcomes and higher healthcare costs for these populations.\n",
       "\n",
       "<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">6</span>. **Age and Gender:**\n",
       "   - Lung function naturally declines with age, making older adults more susceptible to respiratory diseases. \n",
       "Additionally, men historically have higher rates of smoking-related lung diseases, although the gap has narrowed as\n",
       "smoking rates among women have increased. Age-related changes in lung structure and function necessitate tailored \n",
       "interventions for older adults at risk of respiratory diseases.\n",
       "\n",
       "**Conclusion:**  \n",
       "The causes and risk factors of lung diseases are multifaceted and interrelated. Environmental exposures, lifestyle \n",
       "choices, genetic predisposition, infectious agents, socioeconomic status, and demographic factors all contribute to\n",
       "the burden of lung diseases. Addressing these factors through public health initiatives, smoking cessation \n",
       "programs, and improved air quality regulations is crucial for reducing the incidence and impact of lung diseases. \n",
       "Further research is needed to explore the interplay of these factors and develop targeted interventions.\n",
       "\n",
       "**Recommendations:**\n",
       "- Promote public awareness campaigns focused on smoking cessation and the dangers of secondhand smoke.\n",
       "- Implement stricter regulations on air quality and occupational safety standards.\n",
       "- Encourage regular health screenings and access to healthcare services, particularly in at-risk populations.\n",
       "- Invest in research to better understand the genetic and environmental interactions leading to lung diseases.\n",
       "\n",
       "This report provides a comprehensive overview of the causes and risk factors associated with lung diseases, \n",
       "offering insights into potential areas for intervention and further research.\n",
       "</pre>\n"
      ],
      "text/plain": [
       "### Task Output ###\n",
       "**Report on Causes and Risk Factors of Lung Diseases**\n",
       "\n",
       "**Introduction:**  \n",
       "Lung diseases encompass a wide range of conditions affecting the lungs and respiratory system, including chronic \n",
       "obstructive pulmonary disease \u001b[1m(\u001b[0mCOPD\u001b[1m)\u001b[0m, asthma, lung cancer, pneumonia, and interstitial lung disease. Understanding \n",
       "the causes and risk factors associated with these diseases is crucial for prevention and management.\n",
       "\n",
       "**Key Findings:**\n",
       "\n",
       "\u001b[1;36m1\u001b[0m. **Environmental Factors:**\n",
       "   - **Air Pollution:** Exposure to particulate matter \u001b[1m(\u001b[0mPM\u001b[1m)\u001b[0m, nitrogen dioxide \u001b[1m(\u001b[0mNO2\u001b[1m)\u001b[0m, and sulfur dioxide \u001b[1m(\u001b[0mSO2\u001b[1m)\u001b[0m is \n",
       "linked to the development and exacerbation of respiratory diseases. Long-term exposure to poor air quality is \n",
       "associated with increased rates of asthma and COPD. Studies have shown that urban areas with high traffic emissions\n",
       "often correlate with higher incidences of respiratory illnesses among residents.\n",
       "   - **Occupational Hazards:** Certain occupations expose individuals to harmful substances such as asbestos, \n",
       "silica, and coal dust, increasing the risk of lung diseases. Workers in construction, mining, and manufacturing are\n",
       "particularly vulnerable. For instance, miners are at risk of pneumoconiosis, a lung disease caused by inhaling coal\n",
       "dust.\n",
       "   - **Secondhand Smoke:** Non-smokers exposed to tobacco smoke are at a heightened risk of developing lung \n",
       "diseases, including lung cancer and COPD. The World Health Organization reports that secondhand smoke exposure \n",
       "contributes to approximately \u001b[1;36m1.2\u001b[0m million premature deaths annually.\n",
       "\n",
       "\u001b[1;36m2\u001b[0m. **Lifestyle Factors:**\n",
       "   - **Smoking:** The leading cause of lung diseases, smoking is responsible for approximately \u001b[1;36m85\u001b[0m% of lung cancer \n",
       "cases and significantly contributes to the incidence of COPD and chronic bronchitis. The risk is dose-dependent, \n",
       "meaning the more one smokes, the higher the risk. Quitting smoking can lead to substantial reductions in risk over \n",
       "time, improving lung health and overall quality of life.\n",
       "   - **Physical Inactivity:** A sedentary lifestyle can exacerbate respiratory conditions and reduce lung function.\n",
       "Regular physical activity is associated with better respiratory health outcomes, helping to maintain optimal lung \n",
       "function and improve overall well-being.\n",
       "\n",
       "\u001b[1;36m3\u001b[0m. **Genetic Predisposition:**\n",
       "   - Genetic factors play a role in the susceptibility to lung diseases. For instance, individuals with a family \n",
       "history of asthma or COPD may be at a higher risk. Genetic mutations, such as those affecting the alpha-\u001b[1;36m1\u001b[0m \n",
       "antitrypsin protein, can lead to conditions like emphysema. Advances in genetic research are paving the way for \n",
       "personalized medicine and targeted therapies based on individual genetic profiles.\n",
       "\n",
       "\u001b[1;36m4\u001b[0m. **Infectious Agents:**\n",
       "   - **Viruses and Bacteria:** Respiratory infections, particularly during childhood, can lead to long-term \n",
       "respiratory issues. Viral infections like respiratory syncytial virus \u001b[1m(\u001b[0mRSV\u001b[1m)\u001b[0m and bacterial infections like \n",
       "Streptococcus pneumoniae can contribute to the development of chronic respiratory diseases. For example, children \n",
       "with severe RSV infections may be at an increased risk for developing asthma later in life.\n",
       "   - **Fungal Exposure:** Certain environmental fungi can cause respiratory problems, particularly in \n",
       "immunocompromised individuals. For example, Aspergillus species can lead to allergic bronchopulmonary \n",
       "aspergillosis, a condition characterized by wheezing and coughing.\n",
       "\n",
       "\u001b[1;36m5\u001b[0m. **Socioeconomic Factors:**\n",
       "   - Individuals from lower socioeconomic backgrounds may have limited access to healthcare, leading to delayed \n",
       "diagnosis and treatment of lung diseases. Factors such as poor housing conditions, lack of education, and limited \n",
       "resources for health promotion further exacerbate vulnerability. Inadequate access to preventive services and early\n",
       "interventions can lead to worse health outcomes and higher healthcare costs for these populations.\n",
       "\n",
       "\u001b[1;36m6\u001b[0m. **Age and Gender:**\n",
       "   - Lung function naturally declines with age, making older adults more susceptible to respiratory diseases. \n",
       "Additionally, men historically have higher rates of smoking-related lung diseases, although the gap has narrowed as\n",
       "smoking rates among women have increased. Age-related changes in lung structure and function necessitate tailored \n",
       "interventions for older adults at risk of respiratory diseases.\n",
       "\n",
       "**Conclusion:**  \n",
       "The causes and risk factors of lung diseases are multifaceted and interrelated. Environmental exposures, lifestyle \n",
       "choices, genetic predisposition, infectious agents, socioeconomic status, and demographic factors all contribute to\n",
       "the burden of lung diseases. Addressing these factors through public health initiatives, smoking cessation \n",
       "programs, and improved air quality regulations is crucial for reducing the incidence and impact of lung diseases. \n",
       "Further research is needed to explore the interplay of these factors and develop targeted interventions.\n",
       "\n",
       "**Recommendations:**\n",
       "- Promote public awareness campaigns focused on smoking cessation and the dangers of secondhand smoke.\n",
       "- Implement stricter regulations on air quality and occupational safety standards.\n",
       "- Encourage regular health screenings and access to healthcare services, particularly in at-risk populations.\n",
       "- Invest in research to better understand the genetic and environmental interactions leading to lung diseases.\n",
       "\n",
       "This report provides a comprehensive overview of the causes and risk factors associated with lung diseases, \n",
       "offering insights into potential areas for intervention and further research.\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from praisonai import PraisonAI\n",
    "from google.colab import userdata\n",
    "\n",
    "# Create a PraisonAI instance with the agent_yaml content\n",
    "praisonai = PraisonAI(agent_yaml=agent_yaml, tools=[YouTubeSearchTool])\n",
    "\n",
    "# Add OPENAI_API_KEY Secrets to Google Colab on the Left Hand Side 🔑 or Enter Manually Below\n",
    "os.environ[\"OPENAI_API_KEY\"] = userdata.get('OPENAI_API_KEY') or \"ENTER OPENAI_API_KEY HERE\"\n",
    "os.environ[\"OPENAI_MODEL_NAME\"] = \"gpt-5-nano\"\n",
    "\n",
    "# Run PraisonAI\n",
    "result = praisonai.run()\n",
    "\n",
    "# Print the result\n",
    "print(result) # 8/10\n"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3",
   "name": "python3"
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
